package com.ruoyi.dailyoperations.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.dailyoperations.domain.AccountRecharge;
import com.ruoyi.dailyoperations.service.IAccountRechargeService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 充值信息统计Controller
 * 
 * @author ruoyi
 * @date 2024-09-14
 */
@RestController
@RequestMapping("/recharge")
public class AccountRechargeController extends BaseController
{
    @Autowired
    private IAccountRechargeService accountRechargeService;

    /**
     * 查询充值信息统计列表
     */
    @RequiresPermissions("dailyoperations:recharge:list")
    @GetMapping("/list")
    public TableDataInfo list(AccountRecharge accountRecharge)
    {
        startPage();
        List<AccountRecharge> list = accountRechargeService.selectAccountRechargeList(accountRecharge);
        return getDataTable(list);
    }

    /**
     * 导出充值信息统计列表
     */
    @RequiresPermissions("dailyoperations:recharge:export")
    @Log(title = "充值信息统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AccountRecharge accountRecharge)
    {
        List<AccountRecharge> list = accountRechargeService.selectAccountRechargeList(accountRecharge);
        ExcelUtil<AccountRecharge> util = new ExcelUtil<AccountRecharge>(AccountRecharge.class);
        util.exportExcel(response, list, "充值信息统计数据");
    }

    /**
     * 获取充值信息统计详细信息
     */
    @RequiresPermissions("dailyoperations:recharge:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(accountRechargeService.selectAccountRechargeById(id));
    }

    /**
     * 新增充值信息统计
     */
    @RequiresPermissions("dailyoperations:recharge:add")
    @Log(title = "充值信息统计", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AccountRecharge accountRecharge)
    {
        return toAjax(accountRechargeService.insertAccountRecharge(accountRecharge));
    }

    /**
     * 修改充值信息统计
     */
    @RequiresPermissions("dailyoperations:recharge:edit")
    @Log(title = "充值信息统计", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AccountRecharge accountRecharge)
    {
        return toAjax(accountRechargeService.updateAccountRecharge(accountRecharge));
    }

    /**
     * 删除充值信息统计
     */
    @RequiresPermissions("dailyoperations:recharge:remove")
    @Log(title = "充值信息统计", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(accountRechargeService.deleteAccountRechargeByIds(ids));
    }
}
